package com.wwl.collection;

import java.util.*;

public class MapDemo {
    public static void main(String[] args) {
        Map<String,String> map =new HashMap<>();
        map.put("001","Tom");
        map.put("002","Mike");
        map.put("003","Rose");
        System.out.println(map.size());
        System.out.println(map.containsKey("001"));
        System.out.println(map.containsValue("Tom"));

        String obj= (String) map.get("001");
        System.out.println(obj);

        //获取key的集合
        Set<String> set = map.keySet();
        Iterator<String> it = set.iterator();
        while(it.hasNext()){
            String key=it.next();
            String value = map.get(key);
        }
        //获取value集合
        Collection<String> values = map.values();


        Set<Map.Entry<String,String>> abc = map.entrySet();
        Iterator<Map.Entry<String,String>> it9 = abc.iterator();
        while(it9.hasNext())
        {
            Map.Entry<String,String> en = it9.next();
            String key = en.getKey();
            String value = en.getValue();
            System.out.println("key="+key+",value="+value);
        }
    }
}
